are GUI programs really different?
Contrary to common "wisdom", GUI programs in general, and especially GUI
programs constructed from convenience functions, are practically identical structurally to
conventional non-GUI programs. Consider the following common code from a
conventional program :
DO
GOSUB DisplayCommands ' prints a list of command
strings
a$ = INLINE$ ("enter command ===>> ") ' wait for user input
IF a$ THEN GOSUB Callback ' if command received then
process it
LOOP
'
SUB Callback
SELECT CASE a$
CASE "Help" : GOSUB Help ' user typed
"Help"
CASE "Move" : GOSUB Move ' user typed
"Move"
CASE "Rotate" : GOSUB Rotate ' user typed
"Rotate"
.... : more commands ' user typed commands
CASE ELSE : READ
"Say What?" ' user typed garbage
END SELECT
END SUB
GUI programs do the same thing. They display a menu of commands, wait for a user
reply, call a routine to process the command, then loop. The only difference is that
the conventional program reads the menu while the GUI program puts the commands on buttons
or menu bars. And while the conventional program always inputs the command as a line
of text, the GUI program can also respond to button clicks and menu selections. But
in essence, both are structurally identical.
The equivalent program with convenience functions is something like:
GOSUB DisplayCommands ' displays a window with buttons
or menubar or ???
DO
XgrProcessMessages (1) ' wait for user input
DO WHILE XuiGetNextCallback (@grid, @message$, @v0, @v1, @v2, @v3, @kid, @r1$)
GOSUB Callback ' if command received, process it
LOOP
LOOP
RETURN
'
SUB Callback
SELECT CASE r1$
CASE "Help" : GOSUB Help ' grid name =
"Help"
CASE "Move" : GOSUB Move ' grid name =
"Move"
CASE "Rotate" : GOSUB Rotate ' grid name =
"Rotate"
.... : more commands ' grid name = ...
CASE ELSE : XuiMessage (@"Say What?") ' not
known
END SELECT
END SUB
GOSUB DisplayCommands does the same thing different
ways.
a$ = INLINE$() becomes XgrProcessMessages (1) .
The subroutine is the same.
And you thought GUI programs were radically "different".
Think again!